package com.jrx.anytxn.investor.mapper.ext;

import com.jrx.anytxn.investor.entity.AmAccountMainInvestorInfo;
import com.jrx.anytxn.investor.mapper.base.AmAccountMainInvestorInfoMapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * 交易账户mapper扩展
 *
 * @author liuyang
 * @date 2020-05-21
 **/
public interface ExtAmAccountMainInvestorInfoMapper extends AmAccountMainInvestorInfoMapper {

    /**
     * 根据loanId、type、customerId、postingDate查询条数
     *
     * @param investorLoanId 订单id
     * @param type           账户类型
     * @param customerId     客户id
     * @param postingDate    入账日期
     * @param tenantId       租户id
     * @return Integer 满足条数的数量
     * @author liuyang
     * @date 2020-05-25
     */
    Integer selectCountByPostingDataAndInvestorLoanIdAndType(@Param("investorLoanId") String investorLoanId, @Param("type") String type,
                                                             @Param("customerId") String customerId,
                                                             @Param("postingDate") Date postingDate,
                                                             @Param("tenantId") String tenantId);

    /**
     * 批量插入账户信息
     *
     * @param accountMainInfos 账户信息
     * @return int 插入的条数
     * @author liuyang
     * @date 2020-05-21
     */
    int batchInsertAccount(List<AmAccountMainInvestorInfo> accountMainInfos);

    /**
     * 根据对客订单号获取所有资金方的交易账户
     *
     * @param loanId
     * @param typeList
     * @param customerId
     * @param tenantId
     * @param statusList
     * @return
     */
    List<AmAccountMainInvestorInfo> selectAccounts(String loanId, List<String> typeList, String customerId, String tenantId, List<String> statusList);

    /**
     * 批量更新
     *
     * @param updateAcctList
     */
    void batchUpdate(List<AmAccountMainInvestorInfo> updateAcctList);


    /**
     * 根据出资方贷款id，客户id，账户类型，期数，账户状态查询交易账户
     *
     * @param investorLoanId 出资方贷款id
     * @param customerId     客户id
     * @param tenantId       租户id
     * @param typeList       账户类型
     * @param billingTenor   期数
     * @param statusList     账户状态
     * @return List<AmAccountMainInvestorInfo> 交易账户
     * @author liuyang
     * @date 2020-05-27
     */
    List<AmAccountMainInvestorInfo> selectAccount(@Param("investorLoanId") String investorLoanId,
                                                  @Param("customerId") String customerId,
                                                  @Param("tenantId") String tenantId,
                                                  @Param("typeList") List<String> typeList,
                                                  @Param("billingTenor") Integer billingTenor,
                                                  @Param("statusList") List<String> statusList);

    /**
     * 批量更新账户信息（用于批量）
     *
     * @param accountMainInfos 账户信息
     * @return int 更新的条数
     * @author liuyang
     * @date 2020-05-27
     */
    int batchUpdateAccountMainInfoForBatch(List<AmAccountMainInvestorInfo> accountMainInfos);


    /**
     * 根据订单查询交易账户
     *
     * @param investorLoanId
     * @return
     */
    List<AmAccountMainInvestorInfo> selectByInvestorLoanId(@Param("investorLoanId") String investorLoanId);

    List<AmAccountMainInvestorInfo> findByCust(@Param("customerId") String customerId,
                                                  @Param("tenantId") String tenantId,
                                                  @Param("statusList") List<String> statusList);

}
